1 #include "Book.h"
2 #include
"BookDatabase.h"
3
4 #include <iostream>
5 #include <fstream>
6 #include <
string>
7 #include <iomanip>

8
9 using
namespace std;
10
11 const
char STUDENT_DATA[] = "student_data.txt";
12
13 void
createBookList(ifstream& infile, BookDatabase& Database)
14 {
15
16
17     Book tempBook;
18     
string bookID,title,author,publisher;
19     
int publication, edition, cost, retailPrice;
20
21     infile >> bookID;
22
23     
while (bookID != "END")
24     {
25         
if (infile.peek() == ' ')
26             infile.ignore();
27         getline(infile, title);
28         getline(infile, author);
29         getline(infile, publisher);
30
31
32         infile >> publication >> edition >> cost >> retailPrice;
33
34
35         tempBook.setBook(bookID, title, author, publisher, publication, edition, cost, retailPrice);
36         Database.addBook(tempBook);
37
38         infile >> bookID;
39     }
40 }

41
42 void
readBookData(BookDatabase& Database)
43 {
44     ifstream infile;
45
46     infile.open(STUDENT_DATA);
47
48     
if (!infile)
49     {
50         cerr <<
"Input file does not exist." << endl;
51         system(
"Pause");
52         exit(
1);
53     }
54
55     createBookList(infile, Database);
56
57     infile.close();
58 }


Gõ tìm kiếm nhanh...